<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="../vue.js"></script>
</head>

<body>
  <div id="app">
    <div>{{count}}</div>
    <!-- 这里的()只是为了传参 如果没有写() 函数中的e即为事件对象-->
    <button @click="add">累加</button>
    <!-- 想要用事件对象e需要传$event -->
    <button @click="addN(2,$event)">累加2</button>
    <button @click="add(e)">累加</button>
    <button @click="decrement(2,$event)">累减2</button>
  </div>
  <script>
    Vue.config.productionTip = false;

    const vm = new Vue({
      el: "#app",
      data() {
        return {
          count: 1
        }
      },
      methods: {
        add(e) {
          this.count++
          console.log(e);
        },
        addN(n, e) {
          this.count += n
          console.log(e);
        },
        decrement(n, e) {
          this.count -= n
        }
      }
    })
  </script>
</body>

</html>